/**
 * 
 */
package br.srv.full.geoProcessing.entities.roads;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @author carlos.pinheiro
 * 
 */
@Entity
@Table(name = "Jurisdicao")
public class Jurisdicao {

	@Id
	@Column(length = 1)
	private String codigo;

	@Column(length = 20)
	private String nome;

	/**
	 * @param codigo
	 *            the codigo to set
	 */
	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	/**
	 * @return the codigo
	 */
	public String getCodigo() {
		return codigo;
	}

	/**
	 * @param nome
	 *            the nome to set
	 */
	public void setNome(String nome) {
		this.nome = nome;
	}

	/**
	 * @return the nome
	 */
	public String getNome() {
		return nome;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return getNome();
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object p_obj) {
		if (p_obj instanceof Jurisdicao) {
			Jurisdicao l_j = (Jurisdicao) p_obj;
			return l_j.getCodigo().equalsIgnoreCase(this.getCodigo());
		}else if (p_obj instanceof String) {
			String l_jStr = (String) p_obj;
			return l_jStr.equalsIgnoreCase(this.getCodigo());
		}
		return false;
	}
}
